use $data\edex_data_analytic, clear

#delimit;


eststo clear;
qui eststo A: logit Y T1 if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1) post;
eststo A1;

qui eststo B: logit Y T2  if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T2) post;
eststo B1;
qui eststo C: logit Y T1 T2 if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo C1;
qui eststo D: logit Y T1 T2 $spec1 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo D1;
qui eststo E: logit Y T1 T2 $spec2 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo E1;
qui eststo F: logit Y T1 T2 $spec3 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo F1;
qui eststo G: logit Y T1 T2 $spec3 i.sch_id if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo G1;
qui eststo H: logit Y T1 T2 $spec3 i.sch_id if cbyrace6==1 & sample==1, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo H1;
qui eststo I: logit Y T1 T2 $spec3 i.sch_id if cbyrace3==1 & sample==1, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
esttab, keep(T1 T2);
qui margins, dydx(T1 T2) post;
eststo I1;
esttab A B C D E F G H I using $tables\table_s10.tex, replace label collabels(none) 
nomtitles mgroups("All Students" "White" "Black", pattern(1 0 0 0 0 0 0 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span) 
keep(T1 T2) cells(b(fmt(2) star) se(fmt(2) par)) starlevels(* 0.10 ** 0.05 *** 0.01) noobs 
stats(tc ss gpa sfe tfe nst r2 r2_a, fmt(0 0 0 0 0 0 2 2) labels("Teacher Controls" "Student SES" "9th Grade GPA" "School FE" 
"Teacher Dyad FE" "Observations" " $ R^2 $ " "Adjusted $ R^2 $")) 
title("Logit Estimates of Effect of Expectations on Educational Attainment" 
\label{table3});

esttab A1 B1 C1 D1 E1 F1 G1 H1 I1 using $tables\table_s10.tex, append label collabels(none) 
nomtitles mgroups("All Students" "White" "Black", pattern(1 0 0 0 0 0 0 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span) 
keep(T1 T2) cells(b(fmt(2) star) se(fmt(2) par)) starlevels(* 0.10 ** 0.05 *** 0.01) noobs 
stats(tc ss gpa sfe tfe nst r2 r2_a, fmt(0 0 0 0 0 0 2 2) labels("Teacher Controls" "Student SES" "9th Grade GPA" "School FE" 
"Teacher Dyad FE" "Observations" " $ R^2 $ " "Adjusted $ R^2 $")) 
title("Logit Estimates of Effect of Expectations on Educational Attainment" 
\label{table3});


eststo clear;
qui eststo A: probit Y T1 if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1) post;
eststo A1;

qui eststo B: probit Y T2  if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T2) post;
eststo B1;
qui eststo C: probit Y T1 T2 if sample, cluster(sch_id);
estadd local tc "No"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo C1;
qui eststo D: probit Y T1 T2 $spec1 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "No"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo D1;
qui eststo E: probit Y T1 T2 $spec2 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "No"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo E1;
qui eststo F: probit Y T1 T2 $spec3 if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "No"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo F1;
qui eststo G: probit Y T1 T2 $spec3 i.sch_id if sample, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo G1;
qui eststo H: probit Y T1 T2 $spec3 i.sch_id if cbyrace6==1 & sample==1, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
qui margins, dydx(T1 T2) post;
eststo H1;
qui eststo I: probit Y T1 T2 $spec3 i.sch_id if cbyrace3==1 & sample==1, cluster(sch_id);
estadd local tc "Yes"; estadd local ss "Yes"; estadd local gpa "Yes"; 
estadd local sfe "Yes"; estadd local tfe "No"; estadd scalar nst = round(e(N),10);
esttab, keep(T1 T2);
qui margins, dydx(T1 T2) post;
eststo I1;
esttab A B C D E F G H I using $tables\table_s11.tex, replace label collabels(none) 
nomtitles mgroups("All Students" "White" "Black", pattern(1 0 0 0 0 0 0 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span) 
keep(T1 T2) cells(b(fmt(2) star) se(fmt(2) par)) starlevels(* 0.10 ** 0.05 *** 0.01) noobs 
stats(tc ss gpa sfe tfe nst r2 r2_a, fmt(0 0 0 0 0 0 2 2) labels("Teacher Controls" "Student SES" "9th Grade GPA" "School FE" 
"Teacher Dyad FE" "Observations" " $ R^2 $ " "Adjusted $ R^2 $")) 
title("Probit Estimates of Effect of Expectations on Educational Attainment" 
);

esttab A1 B1 C1 D1 E1 F1 G1 H1 I1 using $tables\table_s11.tex, append label collabels(none) 
nomtitles mgroups("All Students" "White" "Black", pattern(1 0 0 0 0 0 0 1 1) prefix(\multicolumn{@span}{c}{) suffix(}) span) 
keep(T1 T2) cells(b(fmt(2) star) se(fmt(2) par)) starlevels(* 0.10 ** 0.05 *** 0.01) noobs 
stats(tc ss gpa sfe tfe nst r2 r2_a, fmt(0 0 0 0 0 0 2 2) labels("Teacher Controls" "Student SES" "9th Grade GPA" "School FE" 
"Teacher Dyad FE" "Observations" " $ R^2 $ " "Adjusted $ R^2 $")) 
title("Probit Estimates of Effect of Expectations on Educational Attainment" 
);
